<html lang="java">
<head>
    <title>123</title>
<#--    <script type="text/javascript">
        window.onload = function () {

        }
    </script>-->
    <script type="text/javascript">
        window.onload = function () {
            const myDid = document.getElementById("myDid");
            const opts = myDid.options;
            for (let i = 0; i < opts.length; i++) {
                <#--alert(${employee.dId!'0'});-->
                if (opts[i].value == ${employee.dId!'0'}) {
                    opts[i].selected = true;
                }
            }
            const myRid = document.getElementById("myRid");
            const opts1 = myRid.options;
            for (let i = 0; i < opts1.length; i++) {
                if (opts1[i].value == ${employee.rId!'0'}) {
                    opts1[i].selected = true;
                }
            }

            const mySex = document.getElementById("mySex");
            const opts2 = mySex.options;
            for (let i = 0; i < opts2.length; i++) {
                if (opts2[i].value == "${employee.eSex}") {
                    opts2[i].selected = true;
                }
            }


            var  submit=  document.getElementById("submit");

            var  loginName=  document.getElementById("loginName");
            var  sloginName=  document.getElementById("sloginName");

            loginName.onblur = checkloginName;
            function  checkloginName(){
                return   check(loginName,sloginName,"登录账号");
            }

            var  eName=  document.getElementById("eName");
            var  seName=  document.getElementById("seName");
            eName.onblur = checkeName;
            function  checkeName(){
                return   check(eName,seName,"姓名");
            }

            // var  myDid=  document.getElementById("myDid");
            var  smyDid=  document.getElementById("smyDid");

            myDid.onblur = checkmyDid;
            function  checkmyDid(){
                return   checkselect(myDid,smyDid,"所属部门");
            }
            // var  myRid=  document.getElementById("myRid");
            var  smyRid=  document.getElementById("smyRid");
            myRid.onblur = checkmyRid;
            function  checkmyRid(){
                return   checkselect(myRid,smyRid,"所属职位");
            }

            var  eTel=  document.getElementById("eTel");
            var  seTel=  document.getElementById("seTel");
            eTel.onblur = checkeTel;
            function  checkeTel(){
                return   check(eTel,seTel,"手机号");
            }

            var  eQQ=  document.getElementById("eQQ");
            var  seQQ=  document.getElementById("seQQ");
            eQQ.onblur = checkeQQ;
            function  checkeQQ(){
                return   check(eQQ,seQQ,"QQ");
            }
            var  eAddress=  document.getElementById("eAddress");
            var  seAddress=  document.getElementById("seAddress");
            eAddress.onblur = checkeAddress;
            function  checkeAddress(){
                return   check(eAddress,seAddress,"家庭地址");
            }
            var  eBirthday=  document.getElementById("eBirthday");
            var  seBirthday=  document.getElementById("seBirthday");
            eBirthday.onblur = checkeBirthday;
            function  checkeBirthday(){
                return   checkselect(eBirthday,seBirthday,"出生日期");
            }
            var  eEntryTime=  document.getElementById("eEntryTime");
            var  seEntryTime=  document.getElementById("seEntryTime");
            eEntryTime.onblur = checkeEntryTime;
            function  checkeEntryTime(){
                return   checkselect(eEntryTime,seEntryTime,"入职日期");
            }

            function  check(view,s,text){
                var value = view.value ;
                if(value==null ||value=="" ){
                    s.innerHTML=text+"不能为空";
                    view.focus();
                    return  false;
                }
                else{
                    s.innerHTML="";
                    return true;
                }
            }

            function  checkselect(view,s,text){
                var value = view.value ;
                if(value == 0  || value === null || value === ""){
                    s.innerHTML="请选择"+text;
                    view.focus();
                    return  false;
                }
                else{
                    s.innerHTML="";
                    return true;
                }
            }
            submit.onclick = function () {
                if (checkeName() && checkloginName() &&checkmyDid()&&checkmyRid()
                    &&checkeTel()&&checkeQQ()
                    && checkeAddress() &&checkeBirthday()&&checkeEntryTime()){
                    return  true;
                }
                return  false;
            }
        }
    </script>
    <style type="text/css">
        span{
            color:red ;
        }
        body
        {
            background-size: 100% 100%;
            height: 100%;
            width: 100%;
            text-align: center;
            margin-top: 50px;
            margin-left: auto;
        }
        table{
            text-align: center;
            margin: auto;
            text-decoration-color: #E3E6EB;
        }
        h1{
            font-size: 35px;
            color: #5d5a8b;
        }
    </style>
</head>
<body background="/static/img/2.jpg" >
<h1>修改员工信息</h1>
<form action="/record/updateemployee" method="post">
    <input type="hidden" name="eId" value="${employee.eId!''}">
    <table cellpadding="4" cellspacing="1" >
        <tr>
            <td>登录账号：</td>
            <td><input type="text" value="${employee.loginName!''}" name="loginName" id="loginName" disabled/><span id="sloginName"></span></td>
        </tr>
        <tr>
            <td>姓名：</td>
            <td><input type="text" value="${employee.eName!''}" name="eName" id="eName"/><span id="seName"></span></td>
        </tr>
        <tr>
            <td>所属部门：</td>
            <td>
                <select name="dId" id="myDid">
                    <#list  departments as department>
                        <option value="${department.dId}">${department.dName!''}</option>
                    </#list>
                </select>
                <span id="smyDid"></span>
        </td>
        </tr>
        <#if   currentUser.role.rLevel != 1>
        <tr>
            <td>所属职位：</td>
            <td>
                <select name="rId" id="myRid">
                    <#list  roles as role>
                        <#if   currentUser.role.rLevel == 2>
                            <#if  role.rLevel  <   currentUser.role.rLevel >
                                <option value="${role.rId}">${role.rName}</option>
                            </#if>
                        </#if>
                        <#if   currentUser.role.rLevel == 3>
                            <option value="${role.rId}">${role.rName}</option>
                        </#if>
                    </#list>
                </select>
                <span id="smyRid"></span>
            </td>
        </tr>
        </#if>
        <tr>
            <td>性别：</td>
            <td>
                <select name="eSex"  id="mySex">
                    <#list  sexs as sex>
                        <option >${sex!''}</option>
                    </#list>
                </select>
            </td>
        </tr>
        <tr>
            <td>手机号：</td>
            <td><input type="text" value="${employee.eTel!''}" name="eTel" id="eTel"/><span id="seTel"></span></td>
        </tr>
        <tr>
            <td>QQ：</td>
            <td><input type="text" value="${employee.eQQ!''}" name="eQQ" id="eQQ"/><span id="seQQ"></span></td>
        </tr>
        <tr>
            <td>家庭地址：</td>
            <td><input type="text" value="${employee.eAddress!''}" name="eAddress" id="eAddress"/><span id="seAddress"></span></td>
        </tr>
        <tr>
            <td>出生日期：</td>
            <td><input type="date" value="${employee.eBirthday?string("yyyy-MM-dd")}" name="eBirthday" id="eBirthday"/><span id="seBirthday"></span></td>
        </tr>
        <tr>
            <td>入职日期：</td>
            <td><input type="date" value="${employee.eEntryTime?string("yyyy-MM-dd")}" name="eEntryTime" id="eEntryTime"/><span id="seEntryTime"></span></td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center"><input type="submit" value="提交" id="submit"><input type="button" value="返回" onclick="location.href='/record/selectemployee'"></td>
        </tr>
    </table>
</form>

</body>
</html>